web.tomer_see=(function(){
    return function(page,current,obj,scrollLoad){
        // var customerCode ='07.01.0364',
        //     oldSysContractID=10015857,
        //     xin_contractID=1369;
        var customerCode =getQueryString('customerCode'),
            oldSysContractID=getQueryString("oldSysContractID"),
            xin_contractID=getQueryString('contract_id');

        var huan_contrdi=window.localStorage.getItem("new_contract_id")
        if(huan_contrdi!=null){
            xin_contractID=huan_contrdi
        }
        var user_data = {
            customerCode:customerCode,
            oldSysContractID:oldSysContractID,
            contractID:xin_contractID
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            sessionStorage.setItem("oldContractID",data.customer.old_sys_contract_id);
            if(data.errorCode=="0"){
                localStorage.removeItem('new_contract_id');
                //客户信息
                var tab_data=data.customer,
                    account=data.accountList,
                    edition=data.versionList;
                var interText = doT.template($("#signcontract_bob").text());
                $("#signcontract_lsit").html(interText(tab_data));
                //账户管理
                console.log(account)
                var interText = doT.template($("#account_bob").text());
                $("#account_list").html(interText(account));
                //合同版本管理
                var interText = doT.template($("#edition_bob").text());
                $("#edition_lsit").html(interText(edition));
            }
        };
        web.doAjax(root.inter.getContractDetail,'post',user_data, succCallBack);

    }
})();

//客户信息个修改
web.Customerdetails=(function(){
    return function(){
        var customerCode =getQueryString('customerCode'),
            oldSysContractID=getQueryString("oldSysContractID"),
            contractID=getQueryString('contractID');
        var user_data = {
            customerCode:customerCode,
            oldSysContractID:oldSysContractID,
            contractID:contractID
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if(data.errorCode=="0"){
                var customer=data.customer;
                var interText = doT.template($("#custoedit_bob").text());
                $("#custoedit_list").html(interText(customer));
                var operate_manager_id=getQueryString('operate_manager_id'),
                    operate_manager_name=decodeURI(escape(getQueryString('operate_manager_name')))
                $("#manager").val(operate_manager_name)
                $("#manager").text(operate_manager_id)
                //销售主管查询
                var belong_groupId=data.customer.belong_sale_directorId;
                console.log(belong_groupId)
                var ying = {
                    saleManagerId:belong_groupId
                }
                web.doAjax(root.inter.getSaleManagerById,'post',ying, succCallying);
                //客户归属查询
                var belong_sale_directorId=data.customer.belong_groupId;
                var kehu = {
                    belGroupId:belong_sale_directorId
                }
                web.doAjax(root.inter.getGroupById,'post',kehu, succCallkehu);
                //运营经理
                // var operate_manager_id=data.customer.operate_manager_id;
                // $("#manager").val(123456);
                //提交
                $("#form-member-add").validate({
                    rules: {
                        moli:{
                            required: true,
                        }
                    },
                    submitHandler:function(form){
                        var state=$("#state").val(),
                            manager=$("#manager").text();
                        var quzhi=JSON.parse(web.readCookie("loginData"))
                        var user_data = {
                            newContractState:state,
                            operateManagerId:manager,
                            oldSysContractID:oldSysContractID,
                            contractID:contractID,
                            groupBusinessLicenseAddr:$("#fileUp1").val(),
                            groupOpeningAccountAddr:$("#fileUp2").val(),
                            groupIDcardUrl1:$("#fileUp3").val(),
                            groupIDcardUrl2:"groupIDcardUrl2",
                            groupIDcardUrl3:"groupIDcardUrl3",
                            groupIDcardUrl4:"groupIDcardUrl4",
                            groupLoa:$("#fileUp4").val(),
                            update_name:quzhi.user.name,
                            logo:$("#fileUp5").val(),
                            customerCode:getQueryString('customerCode')
                        }
                        var succCallBack = function (data, status, response) {
                            console.log(data)
                            if(data.errorCode=="0"){
                                window.localStorage.setItem('new_contract_id', data.new_contract_id)
                                layer.msg('修改成功', {icon: 6,time:1000});
                                setTimeout( function () {
                                    var index =  parent.location.reload();
                                    parent.layer.close(index)
                                },1000);
                            }
                        }
                        return web.doAjax(root.inter.editCustomerInfo,'post',user_data, succCallBack);
                    }
                })
            };
        };
        //销售主管查询
        var succCallying = function (data, status, response) {
            console.log(data)
            if(data.errorCode=="0"){
                var text=data.saleManagerInfo.user_name;
                if(!data.saleManagerInfo){
                    $("#groupId_txt").text("暂无数据")
                    return false
                }else{
                    $("#groupId_txt").text(text)
                }
            }
        }
        //客户归属查询
        var succCallkehu = function (data, status, response) {
            //console.log(data)
            if(data.errorCode=="0"){
                var text=data.groupInfo.organization_name;
                if(!data.groupInfo){
                    $("#belGroupId").text("暂无数据")
                    return false
                }else{
                    $("#belGroupId").text(text)
                }
                return false
            }
        }
        return web.doAjax(root.inter.getContractDetail,'post',user_data, succCallBack);
    }
})();
function cancel() {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
    // var index =  parent.location.reload();
    // parent.layer.close(index);
}
